import com.it.WebUtil;
import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.ArrayUtils;

import java.lang.annotation.ElementType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Test {
    static class OOMObject{

    }

    public static void main(String[] args) {
        short rpcid=100;
////        byte[] operCodeByte = Arrays.copyOfRange(WebUtil.intToByteArray(rpcid), 1, 3);
//        byte[] operCodeByte = WebUtil.shortToMinByteArray((short) 100);
//        Short operCode = WebUtil.byteLittleEndianToShort(operCodeByte);
//        System.out.println(operCode);
        //读取消息的长度
        byte[] body="hello wordk".getBytes();
        System.out.println("========输出=================");
        byte[] outByte = WebUtil.shortToMinByteArray(rpcid);
        byte[] bytesCount = ArrayUtils.addAll(outByte, body);


        short dataLength = (short) (bytesCount.length + 1);
        //先将消息长度写入，也就是消息头
        byte[] bytes = WebUtil.shortToMinByteArray(dataLength);
        bytes = ArrayUtils.add(bytes, (byte) 1);
        bytes = ArrayUtils.addAll(bytes, body);
        System.out.println("发送出去的信息");
//        收到的信息

        //先将消息长度写入，也就是消息头
        //我们标记一下当前的readIndex的位置
        byte[] operCodeByte = Arrays.copyOfRange(bytes, 1, 3);
        Short operCode = WebUtil.byteLittleEndianToShort(operCodeByte);
        byte[] data = Arrays.copyOfRange(bytes, 3, bytes.length);
        System.out.println("大厅发送的协议是"+operCode);
        System.out.println(new String(data));
        System.out.println("===========测试结束==========");
//        String dir = System.getProperty("app.workspace");
//        System.out.println(dir);
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");
        list.add("e");
//        for (String e:list
//             ) {
//            if(e.equalsIgnoreCase("a")||e.equalsIgnoreCase("c")){
//                list.remove(e);
//            }
//
//        }
        Iterator<String> it = list.iterator();
        while(it.hasNext()){
            String x = it.next();
            if(x.equals("a")){
                it.remove();
            }
        }
//        for(int i=0;i<list.size();i++){ //循环删除集合中的元素
//          if(list.get(i).equalsIgnoreCase("a")||list.get(i).equalsIgnoreCase("c")){
//                list.remove(i);
//            }
//
//        }
        System.out.println(list);
//        List<OOMObject> lists=new ArrayList<>();
//        while (true){
//            list.add(new OOMObject());
//        }

    }
}
